package util;

import java.util.HashMap;
import java.util.Map;

public final class ParameterMap<K,V> extends HashMap<K,V> {

    private static final long serialVersionUID = 1L;

    public ParameterMap() {
        super();
    }

    public ParameterMap(int initialCapacity) {
        super(initialCapacity);
    }

    public ParameterMap(int initialCapacity, float loadFactor) {
        super(initialCapacity, loadFactor);
    }
    
    public ParameterMap(Map<K,V> map) {
        super(map);
    }

    private boolean locked = false;

    public boolean isLocked() {
        return (this.locked);
    }

    public void setLocked(boolean locked) {
        this.locked = locked;
    }

    @Override
    public void clear() {
        if (locked)
            throw new IllegalStateException("parameterMap.locked");
        super.clear();
    }

    @Override
    public V put(K key, V value) {
        if (locked)
            throw new IllegalStateException("parameterMap.locked");
        return (super.put(key, value));

    }

    @Override
    public void putAll(Map<? extends K,? extends V> map) {
        if (locked)
            throw new IllegalStateException("parameterMap.locked");
        super.putAll(map);
    }

    public V remove(Object key) {
        if (locked)
            throw new IllegalStateException("parameterMap.locked");
        return (super.remove(key));
    }
}
